package com.alien.admin.modules.basic.service;

import com.alien.admin.modules.deploy.domain.DpK8sInstance;
import com.alien.admin.modules.basic.domain.Deployment;
import com.alien.admin.modules.basic.domain.Pod;
import com.alien.admin.modules.basic.domain.PodMetric;
import com.alien.admin.modules.basic.domain.ReplicaSet;

import java.util.List;

/**
 * @description: k8s部署接口
 * @author: zhouseyi
 * @date: 2021/9/27 19:02
 * @version: 1.0
 */
public interface K8sService {

    /**
     * 应用部署
     * @param instance k8s实例
     * @param deploymentYmlText 部署文件
     */
    void deploy(DpK8sInstance instance, String deploymentYmlText);

    /**
     * 健康检查接口
     * @param instance
     * @param namespace
     * @param podName
     */
    boolean healthCheck(DpK8sInstance instance, String namespace, String podName);

    /**
     * @description: 获取日志接口
     * @author: zhouseyi
     * @date: 2021/9/27 19:07
     * @version: 1.0
     */
    String getDeploymentLog(DpK8sInstance instance, String namespace, String podName);

    /**
     * 获取集群的deployment列表
     * @param instance
     * @param namespace
     * @return
     */
    List<Deployment> getDeployments(DpK8sInstance instance, String namespace);

    /**
     * 获取集群的资源使用情况
     * @param instance
     * @param namespace
     * @return
     */
    List<PodMetric> getPodMetrics(DpK8sInstance instance, String namespace);

    /**
     * 获取服务的副本集
     * @param instance
     * @param namespace
     * @param deploymentName
     * @return
     */
    List<ReplicaSet> getReplicaSets(DpK8sInstance instance, String namespace, String deploymentName);

    /**
     * 获取pod列表
     * @param instance
     * @param namespace
     * @param replicaSetName
     * @return
     */
    List<Pod> getPods(DpK8sInstance instance, String namespace, String replicaSetName);

    /**
     * @description: 获取日志接口
     * @author: zhouseyi
     * @date: 2021/9/27 19:07
     * @version: 1.0
     */
    String getPodLog(DpK8sInstance instance, String namespace, String podName);

    /**
     * 回滚到某一个副本集
     * @param instance
     * @param namespace
     * @param deploymentName
     * @return
     */
    void rollback(DpK8sInstance instance, String namespace, String deploymentName, String rollbackReplicaSetName);

}
